<!--
 * @description: 
 * @Author: lal
 * @Date: 2020-05-19 11:28:43
 * @LastEditors: lal
 * @LastEditTime: 2020-07-02 19:41:46
-->

<template>
  <div class="container">
    <div class="about">
      <h1>This is an aboutFGHHHH page windows</h1>
      <button type="button" @click="createChildWindow()">父子窗口</button>
      <button type="button" @click="createModalWindow()">模态窗口</button>
      <button type="button" @click="createFrameWindow()">frame: false窗口</button>
    </div>
  </div>
</template>

<script>
import { ipcRenderer, clipboard } from "electron";
import { mapState, mapMutations } from "vuex";
export default {
  name: "zcs-vue",
  props: {},
  data() {
    return {
      files: [],
      copyValue: "",
      placeholder: "click Copy",
      clipboardPPasteValue: "",
    };
  },
  computed: {
    ...mapState({
      count: state => state.count,
    }),
  },
  created() {},
  methods: {
    ...mapMutations(["increment"]),
    clipboardCopy() {
      if (this.copyValue !== "") this.copyValue = "";
      this.placeholder = "Copied! Paste here to see.";
      clipboard.writeText("Electron Demo!");
    },

    clipboardPPaste() {
      clipboard.writeText("What a demo!");
      const message = `Clipboard contents: ${clipboard.readText()}`;
      this.clipboardPPasteValue = message;
    },
    async messageDialog() {
      const result = await ipcRenderer.invoke("open-information-dialog", {
        message: "渲染进程调用主进程dialog",
        // buttons: ["取消", "确认"],
      });
      console.log(result);
    },

    async createChildWindow() {
      const res = await ipcRenderer.invoke("newWin", {
        parent: true,
      });
      console.log(res);
    },
    async createModalWindow() {
      const res = await ipcRenderer.invoke("newWin", {
        parent: true,

        modal: true,
      });
      console.log(res);
    },
    async createFrameWindow() {
      const res = await ipcRenderer.invoke("newWin", {
        frame: false,
      });
      console.log(res);
    },
    notification() {
      if (Notification && Notification.permission != "denied") {
        var n = new Notification("收到消息", {
          body: "通知的内容",
        });
        n.onclose = function() {
          alert("关闭");
        };
      }
    },
    async mainNotification() {
      await ipcRenderer.invoke("notice", "渲染进程调用主进程通知");
    },
  },
  mounted() {
    this.increment();
  },
};
</script>

<style scoped lang="scss">
#holder {
  height: 100px;
  width: 100px;
  background-color: aqua;
}
</style>
